Micron Document
πŸŽ–οΈGitΠ―Ρ€Π°πŸŽ–οΈ


Displaying Raw β€’ View rendered β€’ Download

core/domain/README.md bd2863243bab6eb213401d949839a2bc74dde7e2 (bd286324) Text, 5.45 KB

Tc9d1d9# `:core:domain`

Tc9d1d9## Overview

The Ta5d6ff`:core:domain` module is the **business-logic layer** of the KMP architecture. It contains exclusively use-case classes β€” no UI, no platform code, no mutable state. Each use case is a thin orchestrator that coordinates one or more repository/model dependencies to fulfil a single application action.

**Targets:** Android Β· JVM Β· iOS (via Ta5d6ff`meshtastic.kmp.library` convention plugin)

Tc9d1d9## Key Responsibilities

Tff7b72- Orchestrate radio configuration reads/writes (config, module config, channels, owner, position)
Tff7b72- Manage remote-admin session lifecycle (per-node passkey negotiation)
Tff7b72- Process radio admin responses and manage mesh log settings
Tff7b72- Data export (CSV mesh log, profile Ta5d6ff`.zip`)
Tff7b72- Profile and security-config import/install
Tff7b72- Node database maintenance (clean, reset, selective purge) and OTA capability checks

Tc9d1d9## Source Structure

Ta5d6ff```
src/commonMain/kotlin/org/meshtastic/core/domain/
β”œβ”€β”€ di/
β”‚ └── CoreDomainModule.kt ← Koin @Module + component scan
└── usecase/
β”œβ”€β”€ session/
β”‚ β”œβ”€β”€ EnsureRemoteAdminSessionUseCase.kt
β”‚ β”œβ”€β”€ EnsureSessionResult.kt
β”‚ └── ObserveRemoteAdminSessionStatusUseCase.kt
└── settings/
β”œβ”€β”€ AdminActionsUseCase.kt
β”œβ”€β”€ CleanNodeDatabaseUseCase.kt
β”œβ”€β”€ ExportDataUseCase.kt
β”œβ”€β”€ ExportProfileUseCase.kt
β”œβ”€β”€ ImportProfileUseCase.kt
β”œβ”€β”€ ImportSecurityConfigUseCase.kt
β”œβ”€β”€ InstallProfileUseCase.kt
β”œβ”€β”€ IsOtaCapableUseCase.kt
β”œβ”€β”€ ProcessRadioResponseUseCase.kt
β”œβ”€β”€ RadioConfigUseCase.kt
└── SetMeshLogSettingsUseCase.kt
```

Tc9d1d9## Notable APIs

Tc9d1d9### `EnsureRemoteAdminSessionUseCase`

Ensures a per-node remote-admin passkey session exists before entering the remote admin UI. Uses a Ta5d6ff`Mutex`-guarded Ta5d6ff`inFlight` map so that double-taps coalesce onto a single Ta5d6ff`Deferred`.

Ta5d6ff```Ta5d6ffkotlin
Tff7b72sealed Tff7b72interface T56d364EnsureSessionResult Tb4b4b4{
Tff7b72data Tff7b72object T56d364AlreadyActive Tb4b4b4: Te6edf3EnsureSessionResult T8b949e// passkey already fresh
Tff7b72data Tff7b72object T56d364Refreshed Tb4b4b4: Te6edf3EnsureSessionResult T8b949e// metadata response arrived
Tff7b72data Tff7b72object T56d364Timeout Tb4b4b4: Te6edf3EnsureSessionResult T8b949e// no response within 30 s
Tff7b72data Tff7b72object T56d364Disconnected Tb4b4b4: Te6edf3EnsureSessionResult T8b949e// radio not connected
Tb4b4b4}
Ta5d6ff```

Tc9d1d9### `RadioConfigUseCase`

Radio configuration read/write operations, all returning the Ta5d6ff`packetId` for async tracking:

| Method | Description |
|---|---|
| Ta5d6ff`setOwner` / Ta5d6ff`getOwner` | Node owner info |
| Ta5d6ff`setConfig` / Ta5d6ff`getConfig` | Ta5d6ff`Config` proto (device, position, power, …) |
| Ta5d6ff`setModuleConfig` / Ta5d6ff`getModuleConfig` | Ta5d6ff`ModuleConfig` proto |
| Ta5d6ff`getChannel` / Ta5d6ff`setRemoteChannel` | Channel configuration |
| Ta5d6ff`setFixedPosition` / Ta5d6ff`removeFixedPosition` | Fixed GPS position |
| Ta5d6ff`setRingtone` / Ta5d6ff`getRingtone` | External notification ringtone |
| Ta5d6ff`setCannedMessages` / Ta5d6ff`getCannedMessages` | Canned message slots |

Tc9d1d9### `AdminActionsUseCase`

Ta5d6ff```Ta5d6ffkotlin
Te6edf3rebootTb4b4b4(Te6edf3destNumTb4b4b4)
Te6edf3shutdownTb4b4b4(Te6edf3destNumTb4b4b4)
Te6edf3factoryResetTb4b4b4(Te6edf3destNumTb4b4b4, Te6edf3isLocalTb4b4b4) T8b949e// also clears local NodeDB when isLocal = true
Te6edf3nodedbResetTb4b4b4(Te6edf3destNumTb4b4b4, Te6edf3preserveFavoritesTb4b4b4, Te6edf3isLocalTb4b4b4)
Ta5d6ff```

Tc9d1d9### `ExportDataUseCase`

Streams all mesh log packets to a CSV Ta5d6ff`BufferedSink`. Columns: date, time, from, sender name/location, received location/elevation, SNR, distance, hop limit, payload.

Tc9d1d9## Dependency Graph

Ta5d6ff```Ta5d6fftext
core:domain
β”œβ”€β”€ core:repository (use-case interfaces & contracts)
β”œβ”€β”€ core:model (domain models)
β”œβ”€β”€ org.meshtastic:protobufs (Meshtastic protobuf types, Maven)
β”œβ”€β”€ core:common
β”œβ”€β”€ core:database
β”œβ”€β”€ core:datastore
└── core:resources
Ta5d6ff```

The generated Mermaid graph below renders project-module edges only β€” external Maven artifacts such as Ta5d6ff`org.meshtastic:protobufs` are not shown, and dashed edges are test-only (e.g. Ta5d6ff`:core:testing`).

Tc9d1d9## DI

All use cases are registered via Koin component scan on Ta5d6ff`org.meshtastic.core.domain`. No manual binding is needed β€” annotate a new use case with Ta5d6ff`@Single` and it is picked up automatically.

Tc9d1d9## Dependency Graph

<!--region graph-->
Ta5d6ff```Ta5d6ffmermaid
Ta5d6ffgraph TB
:core:domain[domain]:::kmp-library
:core:domain -.-> :core:repository
:core:domain -.-> :core:model
:core:domain -.-> :core:common
:core:domain -.-> :core:database
:core:domain -.-> :core:datastore
:core:domain -.-> :core:resources
:core:domain -.-> :core:testing

classDef android-application fill:#CAFFBF,stroke:#000,stroke-width:2px,color:#000;
classDef android-application-compose fill:#CAFFBF,stroke:#000,stroke-width:2px,color:#000;
classDef compose-desktop-application fill:#CAFFBF,stroke:#000,stroke-width:2px,color:#000;
classDef android-feature fill:#FFD6A5,stroke:#000,stroke-width:2px,color:#000;
classDef android-library fill:#9BF6FF,stroke:#000,stroke-width:2px,color:#000;
classDef android-library-compose fill:#9BF6FF,stroke:#000,stroke-width:2px,color:#000;
classDef android-test fill:#A0C4FF,stroke:#000,stroke-width:2px,color:#000;
classDef jvm-library fill:#BDB2FF,stroke:#000,stroke-width:2px,color:#000;
classDef kmp-feature fill:#FFD6A5,stroke:#000,stroke-width:2px,color:#000;
classDef kmp-library-compose fill:#FFC1CC,stroke:#000,stroke-width:2px,color:#000;
classDef kmp-library fill:#FFC1CC,stroke:#000,stroke-width:2px,color:#000;
classDef unknown fill:#FFADAD,stroke:#000,stroke-width:2px,color:#000;

Ta5d6ff```
<!--endregion-->

Served by rngit 1.5.2 - Generated in 0.05s